package com.tiyunge.web.controller.common;

import java.util.List;

import com.tiyunge.common.annotation.Anonymous;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tiyunge.common.core.controller.BaseController;
import com.tiyunge.common.core.domain.AjaxResult;
import com.tiyunge.common.core.page.TableDataInfo;
import com.tiyunge.system.domain.SysKnowledge;
import com.tiyunge.system.service.ISysKnowledgeService;

/**
 * 知识看点公共控制器
 * 
 * @author yejiayu
 *
 */
@RestController
@RequestMapping("/api/knowledge")
@Anonymous
public class KnowledgeController extends BaseController
{
    @Autowired
    private ISysKnowledgeService sysKnowledgeService;

    /**
     * 查询知识看点列表（带分页）
     */
    @GetMapping("/list")
    public TableDataInfo list(SysKnowledge sysKnowledge)
    {
        startPage();
        List<SysKnowledge> list = sysKnowledgeService.selectSysKnowledgeList(sysKnowledge);
        return getDataTable(list);
    }

    /**
     * 获取知识看点详细信息
     */
    @GetMapping(value = "/{knowledgeId}")
    public AjaxResult getInfo(@PathVariable("knowledgeId") Long knowledgeId)
    {
        return success(sysKnowledgeService.selectSysKnowledgeByKnowledgeId(knowledgeId));
    }

    /**
     * 获取所有知识看点（不分页）
     */
    @GetMapping("/all")
    public AjaxResult getAll(SysKnowledge sysKnowledge)
    {
        List<SysKnowledge> list = sysKnowledgeService.selectSysKnowledgeList(sysKnowledge);
        return success(list);
    }

    /**
     * 根据状态查询知识看点
     */
    @GetMapping("/status/{status}")
    public TableDataInfo getByStatus(@PathVariable("status") String status)
    {
        startPage();
        SysKnowledge sysKnowledge = new SysKnowledge();
        sysKnowledge.setStatus(status);
        List<SysKnowledge> list = sysKnowledgeService.selectSysKnowledgeList(sysKnowledge);
        return getDataTable(list);
    }

    /**
     * 根据科目分类查询知识看点
     */
    @GetMapping("/subject/{subjectCategory}")
    public TableDataInfo getBySubjectCategory(@PathVariable("subjectCategory") String subjectCategory)
    {
        startPage();
        SysKnowledge sysKnowledge = new SysKnowledge();
        sysKnowledge.setSubjectCategory(subjectCategory);
        List<SysKnowledge> list = sysKnowledgeService.selectSysKnowledgeList(sysKnowledge);
        return getDataTable(list);
    }
}
